/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ga.coordination;

/**
 *
 * @author hartono
 */
public class Vendor {
   
    public byte xPosition;
    public byte yPosition;
    public char idVendor;
    public byte idMachineList [];
    public byte totalMachineInVendor;

    public Vendor() {
    }
        
    public Vendor(byte nMachine) {       
        totalMachineInVendor = nMachine;
        idMachineList = new byte[nMachine];
    }

    public Vendor(byte xPosition, byte yPosition, char idVendor, byte[] idMachineList, byte totalMachineInVendor) {
        this.xPosition = xPosition;
        this.yPosition = yPosition;
        this.idVendor = idVendor;
        this.idMachineList = idMachineList;
        this.totalMachineInVendor = totalMachineInVendor;
    }

    public Vendor(Vendor v){
        this.xPosition = v.xPosition;
        this.yPosition = v.yPosition;
        
        this.totalMachineInVendor= v.totalMachineInVendor;
        this.idMachineList = new byte [totalMachineInVendor];// harus di deep copy
        for (byte i=0; i< totalMachineInVendor;i++){
            idMachineList[i] = v.idMachineList[i];
        }        
        this.idVendor = v.idVendor;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (int i =0; i<totalMachineInVendor;i++){
            sb.append(idMachineList[i]);
            sb.append(' ');
        }
        return "Vendor "+idVendor + " (" +xPosition+","+yPosition+") nMachine:" + totalMachineInVendor + " idMachineList:" + sb;
    }
    
    
}
